import { logUnderline, logTitle, logSubTitle, log } from "../utils/index";
function use() {
    logTitle("三、类");
    logSubTitle("1、类");
    logSubTitle("2、继承");
    logSubTitle("3、修饰符"); // 不写默认为 public
    logSubTitle("4、存取器");
    logSubTitle("5、静态属性和方法");
    logSubTitle("6、抽象类");

    class Animal {
        protected _hasEye!: boolean;
        public _name!: string;
        // 静态属性
        static exist: boolean;
        public play(): void {
            log("Animal is playing!");
        }

        // 存取器
        get hasVision(): boolean {
            return this._hasEye;
        }
        set hasVision(hasVision: boolean) {
            this._hasEye = hasVision;
        }
    }

    class Bird extends Animal {
        private _hasWing: boolean = true;
        public fly(): void {
            log(`bird with ${this._hasEye ? "the eye" : ""} is flying`);
        }
    }

    let bird1 = new Bird();
    bird1._name; // 公有
    Animal.exist;
    // bird1._hasWing // 私有报错
    // bird1._hasEye // 受保护报错，只能在自身和子类中使用

    // 抽象类
    abstract class Thing {
        abstract play(): void;
    }


    logUnderline();
}

export default { use };
